﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GSPatEditor.Pat
{
    enum SystemActionType
    {
        None,
        Stand,
        Walk,
        Jump,
        JumpForward,
        Fall,
        FallAttack,
    }

    class SystemAction : Action
    {
        private SystemActionType type;
        private Animation animation;

        public SystemAction(SystemActionType type, Animation animation)
        {
            this.type = type;
            this.animation = animation;
        }

        public override SystemActionType GetSystemActionType()
        {
            return this.type;
        }

        public override void BeginAction(Simulator.Actor actor)
        {
            switch (type)
            {
                case SystemActionType.Stand:
                    //TODO fall label
                    Simulator.ActorActions.ChangeFreeMove(actor);
                    actor.SetMotion(animation, 0);
                    actor.IsInAir = false;
                    actor.VX = 0;
                    actor.VY = 0;
                    break;
                case SystemActionType.Walk:
                    //TODO fall label
                    Simulator.ActorActions.ChangeFreeMove(actor);
                    actor.SetMotion(animation, 0);
                    actor.IsInAir = false;
                    actor.VX = 4;
                    actor.VY = 0;
                    break;
                case SystemActionType.Jump:
                    Simulator.ActorActions.ChangeFreeMove(actor);
                    actor.SetMotion(animation, 0);
                    actor.SitLabel = Simulator.ActorActions.BeginSit;
                    actor.IsInAir = true;
                    actor.VX = 0;
                    actor.VY = -15;
                    break;
                case SystemActionType.JumpForward:
                    Simulator.ActorActions.ChangeFreeMove(actor);
                    actor.SetMotion(animation, 0);
                    actor.SitLabel = Simulator.ActorActions.BeginSit;
                    actor.IsInAir = true;
                    actor.VX = 4;
                    actor.VY = -15;
                    break;
                case SystemActionType.Fall:
                    Simulator.ActorActions.ChangeFreeMove(actor);
                    actor.SetMotion(animation, 0);
                    actor.SitLabel = Simulator.ActorActions.BeginSit;
                    actor.IsInAir = true;
                    break;
                case SystemActionType.FallAttack:
                    Simulator.ActorActions.ChangeFreeMove(actor);
                    actor.SetMotion(animation, 0);
                    actor.SitLabel = Simulator.ActorActions.BeginSit;
                    actor.IsInAir = true;
                    actor.VX = 0;
                    actor.VY = 15;
                    break;
            }
        }
    }
}
